import React from 'react';
import { Route, Redirect } from 'react-router-dom'
class Protect extends React.Component {
  render() {
    let userRole = 'super';
    let isLogin = true;
    let { role } = this.props
    return <>
      {
        isLogin ?
          (role && !role.includes(userRole) ?
            <Redirect to='/404'></Redirect> :
            <Route {...this.props}></Route>) :
          <Redirect to='/login'></Redirect>
      }
    </>;
  }
}
export default Protect